package com.company.thread;

/**
 * @description: some desc
 * @author: ruoan
 * @date: 2020/10/24 16:13
 */
public class Thread17 {


    public static void main(String[] args) {
        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                while (true) {
                    boolean interrupted = Thread.currentThread().isInterrupted();
                    System.out.println("打断标记："+interrupted);
                    if (interrupted) {
                        return;  // 如果有人告诉你你被打断，而且你决定听从
                    }
                }
            }
        }, "t");
        t.start();
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        t.interrupt(); // 告诉t你要打断他，只是设置个打断标记，可能他不管你



    }
}
